package cn.newtouch.fallback;

import cn.newtouch.feign.MovieTicketFeign;
import cn.newtouch.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class MovieTicketFallbackFactory implements FallbackFactory<MovieTicketFeign> {
    @Override
    public MovieTicketFeign create(Throwable throwable) {
        return new MovieTicketFeign() {
            @Override
            public JsonResult buy(Long userId, Long movieId) {
                return JsonResult.error("服务不可达！请稍后重试！！");
            }

            @Override
            public JsonResult watch(Long userId, Long movieId) {
                return JsonResult.error("服务不可达！请稍后重试！！");
            }

            @Override
            public JsonResult list() {
                return JsonResult.error("服务不可达！请稍后重试！！");
            }
        };
    }
}
